<?php session_start();
require_once "function.php";
$book=M()->select('book');
$type=M()->query('select type from book group by type');
error_reporting(false);
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>首页</title>
  <link rel="stylesheet" href="public/semantic.min.css" media="screen" title="no title" charset="utf-8">
  <link rel="stylesheet" href="public/index.css" media="screen" title="no title" charset="utf-8">
</head>
<body>
  <div class="ui menu">
  <div class="header item">网上书店</div>
  <a class="active item">首页</a>
  <?php if ($_SESSION['id']): ?>
  <div class="ui dropdown item" tabindex="0">
    <?php echo $_SESSION['username'] ?>
    <i class="dropdown icon"></i>
    <div class="menu transition hidden" tabindex="-1">
      <div class="item">我的信息</div>
      <div class="item">我的订单</div>
      <?php if ($_SESSION['flag']==1): ?>
        <div class="item"><a href="admin.html">后台管理</a></div>
      <?php endif; ?>
      <div class="item"><a href="action.php?c=login&m=logout">退出登录</a></div>
    </div>
  </div>
  <?php else: ?>
    <a href="login.html" class=" item"> 登录</a>
  <?php endif; ?>
  <div class="right menu">
    <div class="item">
      <div class="ui action left icon input">
        <i class="search icon"></i>
        <input type="text" placeholder="Search">
        <button class="ui button">搜索</button>
      </div>
    </div>
    <div class="ui dropdown item">
      <div class="text">购物车</div>
      <i class="shop icon"></i>
      <div class="menu menu-car">
        

      </div>
    </div>
  </div>
</div>

<div class="ui main-content  grid ">
    <div class="four wide column right-menu">
      <div class="ui styled accordion">
        <?php foreach ($type as $v) {?>
      <div class=" title"><i class="dropdown icon"></i><?php echo $v['type'] ?></div>
      <div class=" content">
        <div class="ui menu vertical">
          <a class="item">2016年</a>
          <a class="item">2015年</a>
          <a class="item">2014年</a>
        </div>
      </div>
      <?php } ?>
    </div>
    </div>
    <div class="twelve wide column ">
      <div class="ui special cards">
        <?php
        foreach ($book as $v) {
        ?>

        <div class="card">
          <div class="dimmable image">
            <div class="ui dimmer">
              <div class="content">
                <div class="center">
                  <a href="bookinfo.php?isbn=<?php echo $v['ISBN'] ?>" class="ui inverted button"> 查看详情</a>
                </div>
              </div>
            </div>
            <img src="public/1.png">
          </div>
          <div class="content">
            <a class="header"><?php echo $v['name'] ?></a>
            <div class="meta">价格: <del>￥<?php echo $v['price'] ?></del>￥ <?php echo $v['price']*$v['discount']/10 ?></div>
            <div class="meta">作者:<?php echo $v['author'] ?> </div>
          </div>
          <div class="extra content">
            <div class="ui buttons">
              <button class="ui button"><i class="star icon"></i>收藏</button>
              <div class="or"></div>
              <button class="ui positive button"><i class="shop icon"></i>加入购物车</button>
            </div>
          </div>
        </div>
        <?php
      }
       ?>
      </div>
    </div>
</div>
  <script src="public/jquery-2.2.0.js" charset="utf-8"></script>
  <script src="public/semantic.min.js" charset="utf-8"></script>
  <script>

  $(document).ready(function() {
    $('.rating').rating('setting', 'clearable', true);
    $('.special.cards .image').dimmer({
      on: 'hover'
    });
    $('.ui.accordion').accordion({
    selector: {
      trigger: '.title '
    }
  })
      $('.ui.menu .ui.dropdown').dropdown({
        on: 'hover'
      });
      $('.ui.menu a.item').on('click', function() {
          $(this)
            .addClass('active')
            .siblings()
            .removeClass('active')
          ;
        });


    })
  ;

  </script>
</body>
</html>
